package v2ch10.tableCellRender;

import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;

/**
 * This renderer renders a color value as a panel with the given color.
 */
public class ColorTableCellRenderer extends JPanel implements TableCellRenderer {
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
	                                               boolean hasFocus, int row, int column) {
		setBackground((Color) value);
		if (hasFocus) setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
		else setBorder(null);
		return this;
	}
}